<?php
class Messagedata_m extends CI_Model{
	function _consttuct() {
		parent::_construct();
		$this->load->database();
	}

	public function msg_insert($arr)
	{
		$this->db->insert('messagedata',$arr);
	}

	public function msg_select($begin,$value)
	{
		$sql ="SELECT * FROM messagedata ORDER BY ? LIMIT ?,?";
		$query = $this->db->query($sql,array('messageid', $begin, $value));
		return $query;
	}

	public function msg_SelectById($id){
		$sql="SELECT * FROM messagedata WHERE messageid = ? ORDER BY 'messageid'";
		$query = $this->db->query($sql,array($id));
		return $query;
	}

	public function msg_update($id,$arr){
		$this->db->where('messageid',$id);
		$this->db->update('messagedata',$arr);
	}

	public function msg_del($id){
		$this->db->where('messageid',$id);
		$this->db->delete('messagedata');
	}

	public function msg_count(){
		return  $this->db->count_all('messagedata');
	}

	public function msg_getpage($value){
		$count=$this->msg_count();
		$page=floor( $count / $value );
		$page_l=$count % $value;
		$pages=array($page,$page_l);
		return $pages;
	}
}
?>